package com.example.social.screen

import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.width
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.livedata.observeAsState
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import androidx.lifecycle.viewmodel.compose.viewModel
import androidx.navigation.NavHostController
import com.example.social.item_view.ThreadListPage
import com.example.social.screen.component.NotThreadList
import com.example.social.viewmodel.HomeViewModel
import com.example.social.viewmodel.UserViewModel

@Composable
fun FollowScreen(navController: NavHostController, uid: String) {
    val homeViewModel: HomeViewModel = viewModel()
    val threadAndUser by homeViewModel.threadsAndUsers.observeAsState(emptyList())

    if (uid.isNotEmpty()) {
        homeViewModel.getListFollowThreadById(uid)
    }

    Column(modifier = Modifier.padding(16.dp)) {
        Text(
            text = "正在关注", style = TextStyle(
                fontSize = 18.sp,
                fontWeight = FontWeight.Bold
            ), modifier = Modifier.padding(start = 20.dp, top = 20.dp, bottom = 20.dp)
        )
        Box(
            modifier = Modifier
                .fillMaxWidth()
                .height(1.dp)
                .width(10.dp)
                .background(Color.LightGray) // 自定义颜色
        )
        if (threadAndUser!=null) {
            ThreadListPage(threadAndUser, navHostController = navController)
        } else {
            NotThreadList("关注用户暂无发布话题")
        }
    }


}